//----------------------------------------------------------------------------------------------
//	Filename:	PointCloudSolver.h
//	Author:		Sandro Spina
//	Date:		21/04/2013
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
#pragma once

#include "UniqueId.h"
#include "SegmentsGraph.h"
#include "ObjStructureGraph.h"
#include "GraphCut.h"
#include "StructureGraph.h"
#include "StructureGraphsForge.h"
#include "PointCloudSegmentation.h"
#include "PointCloudSceneSolution.h"
#include "ModelTraining.h"

#include <Shape\KDTreeMesh.h>

namespace Illumina
{
	namespace Core
	{
		//*******MAIN 
		class PointCloudSolver
		{
			public:
				MaterialGroup *m_pMaterial;
				Environment *m_pEnvironment;
				EngineKernel *m_pEngineKernel;
				//std::vector<PointCloudSceneSolution *> *m_sceneSolutions;    //We can have multiple solutions.
				PointCloudSceneSolution * m_sceneSolution;    //Search space for this scene. Each path is a different solution.
				PointCloudSegmentation *m_sceneToSolve;
				ModelTraining *m_trainedModelsDB;
				std::map<int, PointCloudSegmentation *> *m_pPreloadedScenes; //Map (Cache) of scenes which have been loaded from file.
		
				bool history_viewing_enabled;
				std::vector<int> history_segments_in_view;				

				PointCloudSolver(Environment* p_environment);		
				PointCloudSceneSolution * GetBestSceneSolution();
				int ComputeSearchSpace();
		
				//**********Logs Writing Functions**************
				void WritePointsToASCIIFile(KDTreePointCloud *p_pointCloud, std::string _filepath);
		};
	}
}